<?php /*a:3:{s:62:"D:\projects\original_admin\app\merchant\view\order\review.html";i:1754755535;s:61:"D:\projects\original_admin\app\merchant\view\common\base.html";i:1752764603;s:63:"D:\projects\original_admin\app\merchant\view\common\header.html";i:1754756031;}*/ ?>
<!DOCTYPE html>
<html lang="zh-CN">

<head>
	<meta charset="UTF-8" />
	<meta name="renderer" content="webkit" />
	<meta name="force-rendering" content="webkit" />
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>管理系统</title>
	<script src="/static/merchant/js/jquery-min.js"></script>
	<link rel="stylesheet" href="/static/merchant/layui/css/layui.css">
	<script type="text/javascript" src="/static/merchant/layui/layui.js"></script>
	<link rel="stylesheet/less" type="text/css" href="/static/merchant/css/index.less" />
	<script src="/static/merchant/js/less.js"></script>
    
</head>
<body>
	<main class="CenterMain">
		<header class="Header">
    <div class="logo img_box">
        <img src="/static/merchant/images/logow.png">

    </div>
    <div class="top">
        <ul class="nav-buttons">
            <li id="toggle-btn">

                <span class="desktop-text layui-icon layui-icon-spread-left">
                </span>
                <span class="mobile-text">菜单</span>
            </li>
        </ul>
        <dl class="menu-btn">
            <a class="img_box ">
                <img src="/static/merchant/images/head1.png">
                <i class="msg"></i>
            </a>
            <a class="img_box">
                <img src="/static/merchant/images/head2.png">
            </a>
        </dl>
        <span class="hr"></span>
        <ul class="layui-nav">

            <li class="layui-nav-item" lay-unselect>
                <a href="javascript:;">
                    <img src="/static/merchant/images/sign-user.png" class="layui-nav-img">
                    <span><?php echo htmlentities((string) $userInfo['shop_name']); ?></span>
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="account_info.html">个人信息</a></dd>
                    <dd><a href="account_pwd.html">密码修改</a></dd>
                    <dd style="text-align: center;"><a href="">退出</a></dd>
                </dl>
            </li>
        </ul>
    </div>

</header>
<div class="Sidebar" id="sidebar">
    <ul class="menu">
        <li class="menu-item">
            <div lay-on="url" href="/" class="title">
                <div class="img img_box">
                    <img class="img1" src="/static/merchant/images/nav22.png">
                    <img class="img2" src="/static/merchant/images/nav21.png">
                </div>
                <span>商品管理</span>
                <!-- <i class="layui-icon layui-icon-right"></i> -->
            </div>
        </li>
        <li class="menu-item <?php if($routers == 'order/list'): ?>  active <?php endif; ?>">
            <div class="title">
                <div class="img img_box">
                    <img class="img1" src="/static/merchant/images/nav32.png">
                    <img class="img2" src="/static/merchant/images/nav31.png">
                </div>
                <span>订单管理</span>
                <i class="layui-icon layui-icon-right"></i>
            </div>
            <dl    <?php if($routers == 'order/list' || $routers == 'order/shop_back' || $routers == 'order/review'): ?>  style="display: block;" <?php else: ?> style="display:none;" <?php endif; ?> >
                <dd>
                    <a href="/merchant/order.html"  <?php if($routers == 'order/list'): ?>  class="active" <?php endif; ?> >订单管理</a>
                </dd>
                <dd>
                    <a href="/merchant/shop_back.html" <?php if($routers == 'order/shop_back'): ?>  class="active" <?php endif; ?>>退货管理</a>
                </dd>
                <dd>
                    <a href="/merchant/review.html" <?php if($routers == 'order/review'): ?>  class="active" <?php endif; ?>>订单评价</a>
                </dd>

            </dl>

        </li>
        <li class="menu-item ">
            <div class="title">
                <div class="img img_box">
                    <img class="img1" src="/static/merchant/images/nav42.png">
                    <img class="img2" src="/static/merchant/images/nav41.png">
                </div>
                <span>财务提现</span>
                <i class="layui-icon layui-icon-right"></i>
            </div>

            <dl style="display: none;">
                <dd>
                    <a href="finance_cash.html">提现</a>
                </dd>
                <dd>
                    <a href="finance_logs.html">记录</a>
                </dd>
            </dl>

        </li>
        <!-- <li class="menu-item ">
            <div class="title">
                <div class="img img_box">
                    <img class="img1" src="images/nav52.png">
                    <img class="img2" src="images/nav51.png">
                </div>
                <span>消息中心</span>
                <i class="layui-icon layui-icon-right"></i>
            </div>

        </li> -->
        <li class="menu-item ">
            <div class="title">
                <div class="img img_box">
                    <img class="img1" src="/static/merchant/images/nav62.png">
                    <img class="img2" src="/static/merchant/images/nav61.png">
                </div>
                <span>店铺设置</span>
                <i class="layui-icon layui-icon-right"></i>
            </div>

            <dl style="display: none;">
                <dd>
                    <a href="store_info.html">店铺信息 </a>
                </dd>
                <dd>
                    <a href="store_notice.html">店铺公告</a>
                </dd>
                <dd>
                    <a href="store_model.html">运费模板</a>
                </dd>
            </dl>

        </li>
    </ul>
</div>
		 
<div class="Content" id="content">
    <div class="container">
        <!-- 搜索栏 -->
        <form class="layui-form search-form SearchCom " lay-filter="searchForm">
            <div class="OrderSearcItem">
              

            

                <div class="layui-form-item">
                    <div class="layui-input-wrap">
                        <div class="layui-input-prefix">
                            <i class="layui-icon layui-icon-search"></i>
                        </div>
                        <input type="text" name="keyword" placeholder="订单号/买家/商品名" class="layui-input" value="<?php echo htmlentities((string) (app('request')->param('keyword') ?: '')); ?>">
                    </div>
                    <button class="layui-btn layui-btn-blue" style="margin-right: 20px;" lay-submit lay-filter="search">查询</button>
                </div>
            </div>
        </form>

        <!-- 商品表格 -->
        <table class="layui-hide" id="productTable" lay-filter="productTable" lay-skin="line"></table>
    </div>



    <!-- 操作按钮模板 -->
    <script type="text/html" id="operateTpl">
        <div class="foot">
            <a class="btn-delete" lay-event="delete" style="color: #ff5722;">删除</a>
        </div>
    </script>
</div>

	</main>
</body>
<script  src="/static/merchant/js/index.js"></script>
<script src="/static/merchant/js/base.js"></script>
 
<script>
    changeTitleName('评论管理')
    function showImageLightbox(currentImg) {
        window.open(currentImg, '_blank');
    }
    layui.use(['table', 'form', 'laydate','layer'], function () {
        var table = layui.table;
        var form = layui.form;
        var layer = layui.layer;
        var $ = layui.$;
       
        

        // 初始化表格
        var tableIns = table.render({
            elem: '#productTable',
            url: '/merchant/merchant-order-review',
            height: 'full-100',

            page: {
                limit: 17,
                limits: [10, 17, 20, 30],
                groups: 5,
                prev: '<',
                next: '>',
                layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
                theme: '#1E9FFF'
            },
            cols: [
                [
                    {
                        field: 'store_name',
                        title: '商品信息',
                        width:400,
                        templet: function(d) {
                            // 这里假设商品图片字段是 thumb 或 image
                            var imgUrl = d.image ;
                            
                            return `
                                <div style="display: flex; align-items: center;">
                                    <div style="width: 50px; height: 50px; margin-right: 10px;">
                                        <img src="${imgUrl}" style="width: 100%; height: 100%; object-fit: cover;">
                                    </div>
                                    <div>${d.store_name || '无名称'}</div>
                                </div>
                            `;
                        }
                    },
                    
                    {
                        field: 'order_id', 
                        title: '订单信息', 
                        width: 300,
                        templet: function(d) {
                            // 确保有订单数据
                            const order = d.order || {};
                            
                            // 格式化支付时间
                            const payTime = order.pay_time ? new Date(order.pay_time * 1000).toLocaleString() : '未支付';
                            
                            return `
                                <div style="line-height: 1.6;">
                                    <div>
                                        <span style="font-weight: bold;">订单编号：</span>
                                        <span>${order.order_id || '无'}</span>
                                    </div>
                                    <div>
                                        <span style="font-weight: bold;">支付金额：</span>
                                        <span style="color: #f56c6c;">¥${order.pay_price || '0.00'}</span>
                                    </div>
                                    <div>
                                        <span style="font-weight: bold;">支付时间：</span>
                                        <span style="color: #909399;">${payTime}</span>
                                    </div>
                                </div>
                            `;
                        }
                    },
                    { field: 'comments', title: '评价内容' ,width:400, },
                    {
                        field: 'images',
                        title: '评价图片',
                        width: 200,
                        templet: function(d) {
                            // 确保images是数组格式（如果是字符串先分割）
                            let images = Array.isArray(d.images) ? d.images : 
                                        (typeof d.images === 'string' ? d.images.split(',') : []);
                            
                            // 过滤空值
                            images = images.filter(img => img && img.trim());
                            
                            if (images.length === 0) return '无图片';
                            
                            return `
                                <div style="display: flex; flex-wrap: wrap; gap: 5px;">
                                    ${images.map(img => `
                                        <img src="${img}" 
                                             style="width: 50px; height: 50px; object-fit: cover; cursor: pointer;"
                                             onclick="showImageLightbox('${img}')">
                                    `).join('')}
                                </div>
                            `;
                        }
                    },
                    {
                        field: 'user',
                        title: '评价用户',
                        width: 180,
                        templet: function(d) {  
                            return `
                                <div style="display: flex; align-items: center; gap: 8px;">
                                    <img src="${d.avatar}" 
                                         style="width: 32px; height: 32px; border-radius: 50%; object-fit: cover;">
                                    <div style="font-weight: 500; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">
                                            ${d.user.nickname || '匿名用户'}
                                    </div>
                                </div>
                            `;
                        }
                    },
                    {
                        field: 'level',
                        title: '评价等级',
                        width: 200,
                        templet: function(d) {
                            const level = parseInt(d.level) || 0;
                            const maxLevel = 5; // 最大5星
                            
                            return `
                                <div style="color: #FFB800; font-size: 16px;">
                                    ${Array.from({length: maxLevel}, (_, i) => 
                                        `<i class="layui-icon ${i < level ? 'layui-icon-rate-solid' : 'layui-icon-rate'}"></i>`
                                    ).join('')}
                                    <span style="color: #666; font-size: 14px; margin-left: 5px;">${level}.0</span>
                                </div>
                            `;
                        }
                    },
                    { field: 'create_time', title: '评价时间' },
                    {
                        title: '操作',
                        width: 160,
                        toolbar: '#operateTpl'
                    }
                ]
            ]
        });


        table.on('tool(productTable)', function(obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'delete':
                    layer.confirm('确定要删除这条评论吗？', function(index){
                        $.post('/merchant/merchant-review-delete', {
                            id: data.id
                        }, function(res){
                            if(res.code === 200){
                                layer.msg('删除成功', {icon: 1});
                                tableIns.reload();
                            }else{
                                layer.msg(res.msg || '删除失败', {icon: 2});
                            }
                        });
                        layer.close(index);
                    });
                    break;
                case 'cancel':
                    // 原有取消订单逻辑...
                    break;
                case 'deliver':
                    // 原有发货逻辑...
                    break;
                case 'refund':
                    // 原有退款逻辑...
                    break;
            }
        });

        // 获取URL参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURI(r[2]); return null;
        }

        // 更新URL参数（不刷新页面）
        function updateUrlParam(key, value) {
            var url = window.location.href;
            var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
            var separator = url.indexOf('?') !== -1 ? "&" : "?";
            
            if (url.match(re)) {
                url = url.replace(re, '$1' + key + "=" + value + '$2');
            } else {
                url = url + separator + key + "=" + value;
            }
            
            history.pushState(null, null, url);
        }

        // 监听窗口大小变化
        window.onresize = function() {
            table.resize('productTable');
        };
    });
</script>
>
</html>